﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLToolkit.Data;

namespace MvcVietAir.Models
{
    public class RepositoryNews
    {
        private DbManager db = new DbManager("MvcVietAirConnectionString");
        //
        public List<News> GetAll(int type)
        {
            using (db)
            {
                return db.SetSpCommand("News_GetAll", db.Parameter("@NewsType", type)).ExecuteList<News>();
            }
        }
        public List<News> AllNewsTours(string extraInfo)
        {
            using (db)
            {
                return db.SetSpCommand("News_AllNewsTours", db.Parameter("@ExtraInfo", extraInfo)).ExecuteList<News>();
            }
        }
        public List<News> AllNewsHotels(string extraInfo)
        {
            using (db)
            {
                return db.SetSpCommand("News_AllNewsHotels", db.Parameter("@ExtraInfo", extraInfo)).ExecuteList<News>();
            }
        }
        public List<News> FindByKeys(string keys)
        {
            using (db)
            {
                return db.SetSpCommand("News_FindByKeys", db.Parameter("@Keys", keys)).ExecuteList<News>();
            }
        }
        public News Single(string id)
        {
            using (db)
            {
                return db.SetSpCommand("News_Single", db.Parameter("@Id", Convert.ToInt32(id))).ExecuteObject<News>();
            }
        }
    }
}